<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title>分页界面</title>
    <link rel="stylesheet" type="text/css" href="${s.base}/lib/layui/css/layui.css"/>
    <link rel="stylesheet" type="text/css" href="${s.base}/css/base/index.css"/>
    <link rel="stylesheet" type="text/css" href="${s.base}/css/base/theme/theme.css"/>
</head>
<body>
<div class="wrap-container clearfix">
    <div class="column-content-detail">
        <form class="layui-form" method="post" action="/work/asset/exportWarranty">
            <div class="search-cont clearfix" id="tool">
                <div class="operation-btn-cont">
                    <div class="operright cyt-retract-close hideMenu"> 收起筛选<i class="iconfont">&#xe658;</i></div>
                    <div class="operright cyt-retract-open showMenu" style="display: none;"> 展开筛选<i class="iconfont">&#xe936;</i></div>
                    <!--button开始-->
                    <button class="layui-btn layui-btn-normal layui-btn-mid" type="button" id="addBtn"><i class="iconfont marr5">&#xe65e;</i>新增</button>
                    <button class="layui-btn layui-btn-normal layui-btn-mid" type="button" id="editBtn"><i class="iconfont marr5">&#xe606;</i>编辑</button>
                    <button class="layui-btn layui-btn-normal layui-btn-mid" type="button" id="deleteBtn"><i class="iconfont marr5">&#xe6a3;</i>删除</button>

                    <!--button结束-->
                    <div class="triangle-bottom"></div>
                    <div class="triangle-top"></div>
                </div>
                <div class="search-details">
                    <div class="layui-form-item marb5">
                        <!--search开始-->
                        <div class="layui-inline">
                            <label class="layui-form-label">考务名称：</label>
                            <div class="layui-input-inline">
                                <input type="text" name="title" id="title" placeholder="请输入名称" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <!--search结束-->
                        <div class="layui-inline marl8">
                            <button class="layui-btn layui-btn-normal" type="button" lay-submit="" lay-filter="seacherBtn">搜索</button>
                            <button class="layui-btn layui-btn-normal" type="reset">重置</button>
                        </div>
                    </div>
                </div>
            </div>
        </form>
        <div class="layui-form" id="table-list">
            <table id="entityList" lay-filter="entityList" class="cy-list-table"></table>
        </div>
    </div>
</div>
<!--操作-->
<script src="${s.base}/lib/layui/layui.js" type="text/javascript" charset="utf-8"></script>
<script src="${s.base}/js/common.js" type="text/javascript" charset="utf-8"></script>
<script>

    //监听添加按钮事件
    function show(id) {
        var menuId=parent.getTabId();
        page.edit("kwStudentMessageListEdit","/work/kwmanagement/kwStudentMessageDetail?applyId="+applyId+"&ksId="+id+"&parentMenuId="+menuId,"发布考试通知");
    }

    var applyId='${applyId}';
    var tableIns = null;
    var page = null;
    var cols =[];
    layui.use(['jquery', 'table', 'page', 'dialog', 'baseutil'], function () {
        var $ = layui.jquery,
            table = layui.table,
            dialog = layui.dialog;
            page = layui.page;
            baseutil = layui.baseutil;

            //获取分页数据
            var url = "/work/kwmanagement/kwmanagement/page?applyId="+applyId;
             cols = [
                {type: 'checkbox', fixed: 'left'},
                {
                    field: 'title', title: '考务名称', align: 'center',width:"25%", templet: function (d) {
                    if(d.state=="1"){
                        return '<div onclick="show(\''+ d.id+'\')" class="color-blue">' + d.title + '</div>';
                    }else {
                        return '<div>' + d.title +'</div>';
                    }

                }
                },
                {field: 'address', title: '考试地点',width:"25%", align: 'center'},
                {
                    field: 'startTime', title: '开始时间',width:"25%", align: 'center', templet: function (d) {
                    return new Date(d.startTime).Format("yyyy-MM-dd hh:mm");
                }
                },
                {
                    field: 'endTime', title: '结束时间', align: 'center', templet: function (d) {
                    return new Date(d.endTime).Format("yyyy-MM-dd hh:mm");
                }
                }
            ];
            tableIns = page.initDate(cols, url);
            table.reload();


        //添加考务操作
        $('#addBtn').bind('click', function () {
            var menuId=parent.getTabId();
            page.edit("kwmangementEdit","/work/kwmanagement/kwmangementEdit?applyId="+applyId+"&parentMenuId="+menuId,"新增考务安排");
        });

        //删除考务操作
        $('#deleteBtn').bind('click', function () {
            var data = table.checkStatus('entityList').data;
            if (data.length === 0) {
                dialog.msg("请先选择考务");
                return false;
            } else if (data.length === 1) {
                var id = data[0].id;
                page.delete('/work/kwmanagement/kwmanagement/remove', {"id":id}, "您确定要删除吗？", function () {
                    var url = "/work/kwmanagement/kwmanagement/page";
                    tableIns = page.initDate(cols, url);
                });

            }else {
                dialog.msg("请选择单个考务");
                return false;
            }

        });

        //监听编辑按钮事件
        $('#editBtn').bind('click', function () {
            var menuId=parent.getTabId();
            var data = table.checkStatus('entityList').data;
            if (data.length === 0) {
                dialog.msg("请先选择考务");
                return false;
            } else if (data.length === 1) {
                if (data[0].state === '0') {
                    var step = data[0].step;
                    var id = data[0].id;
                    if (step == "1") {
                        page.edit("kwmangementEdit","/work/kwmanagement/kwmangementEdit?applyId="+applyId+"&ksId="+id+"&parentMenuId="+menuId,"基础信息");
                    } else if (step == "2") {
                        page.edit("getNewEdit","/work/kwmanagement/kwstudentmessage/getNewEdit?applyId="+applyId+"&ksId="+id+"&parentMenuId="+menuId,"导入考生");
                    } else if (step == "3") {
                        page.edit("kwKcSettingEdit","/work/kwmanagement/kwKcSettingEdit?applyId="+applyId+"&ksId="+id+"&parentMenuId="+menuId,"设置考场");
                    } else if (step == "4") {
                        page.edit("kwKcMessageListEdit","/work/kwmanagement/kwKcMessageListEdit?applyId="+applyId+"&ksId="+id+"&parentMenuId="+menuId,"设置监巡考老师");
                    } else if (step == "5") {
                        page.edit("kwStudentMessageListEdit","/work/kwmanagement/kwStudentMessageListEdit?applyId="+applyId+"&ksId="+id+"&parentMenuId="+menuId,"发布考试通知");
                    }

                } else {
                    dialog.msg("已发布考务不能编辑");
                    return false;
                }
            } else if (data.length > 1) {
                dialog.msg("请选择单个考务");
                return false;
            }
        });
        //添加点击时间

    });


</script>
</body>
</html>